package cn.heyige.backend.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "占卜历史记录响应")
public class DivinationHistoryResponse {
    
    @Schema(description = "分页信息")
    private PaginationInfo pagination;
    
    @Schema(description = "占卜记录列表")
    private List<DivinationRecord> records;
    
    @Schema(description = "统计摘要")
    private SummaryInfo summary;
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "分页信息")
    public static class PaginationInfo {
        @Schema(description = "当前页", example = "1")
        private Integer page;
        
        @Schema(description = "每页数量", example = "20")
        private Integer size;
        
        @Schema(description = "总记录数", example = "28")
        private Long total;
        
        @Schema(description = "总页数", example = "2")
        private Integer totalPages;
        
        @Schema(description = "是否有下一页", example = "true")
        private Boolean hasNext;
        
        @Schema(description = "是否有上一页", example = "false")
        private Boolean hasPrevious;
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "占卜记录")
    public static class DivinationRecord {
        @Schema(description = "记录ID", example = "rec_1704097800789")
        private Integer id;
        
        @Schema(description = "占卜问题", example = "今年的事业发展怎么样？")
        private String question;
        
        @Schema(description = "卦象信息")
        private HexagramInfo hexagram;
        
        @Schema(description = "占卜类型", example = "TEXT")
        private String divinationType;
        
        @Schema(description = "是否收藏", example = "false")
        private Boolean isFavorite;
        
        @Schema(description = "是否有AI解读", example = "true")
        private Boolean hasAiInterpretation;
        
        @Schema(description = "标签")
        private List<String> tags;
        
        @Schema(description = "反馈评分")
        private Integer feedbackRating;
        
        @Schema(description = "创建时间")
        private LocalDateTime createdAt;
        
        @Data
        @Builder
        @AllArgsConstructor
        @NoArgsConstructor
        @Schema(description = "卦象信息")
        public static class HexagramInfo {
            @Schema(description = "卦象编码", example = "HUO_TIAN_DA_YOU")
            private String code;
            
            @Schema(description = "卦象名称", example = "火天大有")
            private String name;
            
            @Schema(description = "上卦符号", example = "☲")
            private String upperSymbol;
            
            @Schema(description = "下卦符号", example = "☰")
            private String lowerSymbol;
        }
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "统计摘要")
    public static class SummaryInfo {
        @Schema(description = "总记录数", example = "28")
        private Long totalRecords;

        @Schema(description = "收藏数量", example = "5")
        private Integer favoriteCount;
        
        @Schema(description = "平均评分", example = "4.2")
        private Double averageRating;
    }
}